//
//  FuncViewController.m
//  LibDemo
//
//  Created by Gikki Ares on 2020/9/5.
//

#import "HomeViewController.h"
//#import <SDWebImage/SDWebImage.h>
#import <JsUtilitySdk/JsUtilitySdk.h>
#import <JsUtilitySdk/JsColorManager.h>
#import <JsUtilitySdk/JsListViewController.h>
#import <JsUtilitySdk/JsLogListViewController.h>
@interface HomeViewController ()<JsListViewControllerDelegate>
{
	JsLogoView * mLogoView;
	
}

@end

//FixedUiData
@interface HomeViewController (){
	float mf_logoViewHMargin;
	float mf_logoViewTopMargin;
	float mf_logoViewH;
}

@end

static int LogLevel = JsLogLevelVerbose;
@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
	[JsUtilitySdk initSdk];
	jslog_c(LogLevel,nil,@"HomeViewController/ViewDidLoad", @"xxx");
	self.edgesForExtendedLayout = UIRectEdgeNone;
	UIImageView * iv = [[UIImageView alloc]initWithFrame:CGRectMake(100,200, 100, 100)];
	[self.view addSubview:iv];
	NSURL * url = [NSURL URLWithString:@"https://img.alicdn.com/imgextra/i1/219417768/O1CN01Pp0gVq27FnKLt7YXE_!!219417768.png"];
//	[iv sd_setImageWithURL:url];
	
	UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 400, 100, 100)];
	[btn setBackgroundColor:[JsColorManager morandi_red]];
	[btn addTarget:self action:@selector(onClickLogin) forControlEvents:UIControlEventTouchUpInside];
	[self.view addSubview:btn];
	
	UIBarButtonItem * item = [[UIBarButtonItem alloc]initWithTitle:@"About" style:UIBarButtonItemStylePlain target:self action:@selector(onClickAbout)];
	self.navigationItem.rightBarButtonItem = item;
}

- (void)viewDidLayoutSubviews {
	[super viewDidLayoutSubviews];
	float x,y,w,h;
	float width = self.view.bounds.size.width;
	float height = self.view.bounds.size.height;
	{
		y = mf_logoViewTopMargin;
		x = mf_logoViewHMargin;
		w = width - mf_logoViewHMargin * 2;
		h = [mLogoView wrapContentHeight];
		mLogoView.frame = CGRectMake(x, y, w,h);
		mLogoView.backgroundColor = [JsColorManager morandi_red];
		[mLogoView setNeedsLayout];
	}
}

# pragma mark 4 Delegate

# pragma mark 5 Event

- (void)onClickAbout {
	JsAboutViewController * vc = [[JsAboutViewController alloc]init];
	[self.navigationController pushViewController:vc animated:YES];
}

- (void)onClickLogin {
//	JsListViewController * vc = [JsListViewController new];
	JsLogListViewController * vc = [JsLogListViewController new];
	vc.title = @"Home";
//	vc.delegate = self;
	[self.navigationController pushViewController:vc animated:YES];
}

	// MARK: Delegte
-(NSArray<JsListViewControllerModel *> *)jsListViewControllerSetDatasorce:(JsListViewController *)controller {
	return @[
//		[[JsListViewControllerModel alloc] initWithIndex:@"01" title:@"FuncViewController" desc:@"This is just a demo"],
		[[JsListViewControllerModel alloc] initWithIndex:@"0601" title:@"JsRequestManagerTestController" desc:@"Test JsRequestManager\nTest JsRequestManager\nTest JsRequestManager\nTest JsRequestManager\n"],
		[[JsListViewControllerModel alloc] initWithIndex:@"0901" title:@"MenuViewTestController" desc:@"Test JsRequestManager"],
		[[JsListViewControllerModel alloc] initWithIndex:@"0902" title:@"NavMenuViewController" desc:@"Test JsMenuView"],
		[[JsListViewControllerModel alloc] initWithIndex:@"0903" title:@"MenuViewDefaultItemTestController" desc:@"Test JsMenuView with default JsMenuItemView"],
		[[JsListViewControllerModel alloc] initWithIndex:@"1901" title:@"CardListController" desc:@"Test JsTableView"],
		[[JsListViewControllerModel alloc] initWithIndex:@"2101" title:@"JsBottomInputBarController" desc:@"Test JsTableView"],
		[[JsListViewControllerModel alloc] initWithIndex:@"2102" title:@"JsBottomInputBarBetaController" desc:@"Test JsBottomInputBarBeta"],
		[[JsListViewControllerModel alloc] initWithIndex:@"13" title:@"DisplayTestController" desc:@"Test JsDisplayManager"],
		[[JsListViewControllerModel alloc] initWithIndex:@"27" title:@"TestMailViewController" desc:@"Test JsMailManager"],
		[[JsListViewControllerModel alloc] initWithIndex:@"31" title:@"Js_XXTeaManagerTestController" desc:@"Test XX Tea"],
		[[JsListViewControllerModel alloc] initWithIndex:@"32" title:@"JsMediaPickerViewController" desc:@"PickerMedia"],
		[[JsListViewControllerModel alloc] initWithIndex:@"33" title:@"StringValidatorViewController" desc:@"Validate String"],
	];
}



@end
